#ifndef VIRT_FOLDERS_MGR_H
#define VIRT_FOLDERS_MGR_H

#include <mutex>
#include <map>
#include <string>
#include <vector>

#include "FuseServer.h"
#include "Share.h"

class VirtFoldersMgr {
public:
    VirtFoldersMgr();
    ~VirtFoldersMgr();

    void Destroy();
    DWORD Init(IFSL* fuseServerIFace);
    std::string AddCBVirtFolder(const FileShareList& fileShares);
private:
    static DWORD WINAPI CleanupThread(VirtFoldersMgr* ptr);

    std::string AddVirtFolder(const char* shareNamePrefix,
                              const FileShareList& fileShares);

    BOOL m_bInitialised;
    IFSL* m_fuseServerIFace;
    std::map<std::string, std::pair<uint64_t, bool>> m_activeShares;
    std::string m_lastActiveShare;
    std::mutex m_activeSharesGuard;
    HANDLE m_cleanupThread;
    HANDLE m_cleanupEndEvt;
};

#endif // VIRT_FOLDERS_MGR_H
